import Constants from "@/modules/im/constants";
import it from "element-ui/src/locale/lang/it";

/**
 * 解码聊天消息（从数组解码为一个消息对象）
 * @param origin Object
 * @returns {{}}
 */
export function decodeChatMessage(origin) {
    let result = parseChatMessage(origin)
    return result
}

export function decodeChatMessages(origin) {
    let result = []
    origin.forEach(function (item) {
        result.push(parseChatMessage(item))
    })
    return result
}

function parseChatMessage(item) {
    let message = {}
    message.type = item[0]
    message.sender = item[1]
    // message.receiver = item[1]
    message.msg = item[2]
    message.date = item[3]
    return message
}
